Reflective Visitor Pattern

نویسندگان

  • Yun Mai
  • Michel De Champlain
چکیده

The Visitor pattern wraps associated operations that are performed on the elements of an object structure into a separate object. It allows the software designer to define new kinds of operations over the object structure without changing the classes of this structure. But a well-known drawback of this standard Visitor structure is that extending the object structure is hard. This paper presents the design and implementation of a flexible Visitor pattern based on the reflection technique, we call it the Reflective Visitor pattern. The reflection technique enables the Visitor to perform the run-time dispatch action on itself. The separation of the run-time dispatch action from the object structure makes any extension to the object structure become easy. It also removes the cyclic dependencies between the Visitor and the object structure, so the reusability and extensibility of the system are improved.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Automated reasoning for reflective programs

class Visitor {visit(Object obj) {try {Class obj_class = obj.getClass();String obj_className = obj_class.getName();String methodName = "visit" + obj_className;Class this_class = this.getClass();Method method = this_class.getMethod(methodName, obj_class);method.invoke(this, obj);}catch (NoSuchMethodException e) { }catch (IllegalAccessException e) { }<l...

متن کامل

Scripting Refactorings in Java to Introduce Design Patterns

Introducing design patterns into a program by hand is tedious and error-prone. Refactorings help but manual tasks still remain: you must understand available refactorings, determine a precise sequence of refactorings to invoke, and perform these tasks repetitively to a laborious degree. We present Reflective Refactoring (R), a Java package to automate the introduction of classical design patter...

متن کامل

Auto-generation of Model Visitor Frameworks

The visitor pattern, a well known Gang of Four design pattern, provides a suitable way to add operational behaviour to models. However, as soon as the number of metamodels and visitor implementations start to grow, some of the pattern shortcomings make its usage less convenient. This paper presents how the synergy between the Visitor pattern and MDE has been addressed by two open source project...

متن کامل

The Language of the Visitor Design Pattern

Design patterns have been developed to cope with the vast space of possible different designs within object-oriented systems. One of those classic patterns is the Visitor Pattern that is used for representing an operation to be performed on the elements of an object structure. We present a mapping from the Visitor Pattern to a grammar that defines the set of visit sequences that can be performe...

متن کامل

Visitor-Oriented Programming

Multiple dispatching and the visitor pattern are approaches to making object-oriented programs more extensible. Both have a flavor of pattern matching, thereby moving objectoriented programming closer to functional programming. The key idea of these approaches can be crystallized as a notion of visitor which lies between functions and objects. Can this idea be developed into a new form of visit...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2001